﻿using System;
using System.IO;
using SEXY;
using UnityEngine;

namespace Character
{
	// Token: 0x0200019D RID: 413
	public class ColorParameter_AlloyHSVOffset : ColorParameter_Base
	{
		// Token: 0x06000AE0 RID: 2784 RVA: 0x0003EBBC File Offset: 0x0003CDBC
		public ColorParameter_AlloyHSVOffset()
		{
		}

		// Token: 0x06000AE1 RID: 2785 RVA: 0x0003EBF0 File Offset: 0x0003CDF0
		public ColorParameter_AlloyHSVOffset(bool hasAlpha, float alpha)
		{
			this.hasAlpha = hasAlpha;
			this.alpha = alpha;
		}

		// Token: 0x06000AE2 RID: 2786 RVA: 0x0003EC40 File Offset: 0x0003CE40
		public ColorParameter_AlloyHSVOffset(ColorParameter_AlloyHSVOffset copy)
		{
			this.offset_h = copy.offset_h;
			this.offset_s = copy.offset_s;
			this.offset_v = copy.offset_v;
			this.hasAlpha = copy.hasAlpha;
			this.alpha = copy.alpha;
			this.metallic = copy.metallic;
			this.smooth = copy.smooth;
		}

		// Token: 0x06000AE3 RID: 2787 RVA: 0x0003ECD4 File Offset: 0x0003CED4
		public override COLOR_TYPE GetColorType()
		{
			return COLOR_TYPE.ALLOY_HSV;
		}

		// Token: 0x06000AE4 RID: 2788 RVA: 0x0003ECD8 File Offset: 0x0003CED8
		public void Init(bool hasAlpha = false, float alpha = 1f)
		{
			this.offset_h = 0f;
			this.offset_s = 1f;
			this.offset_v = 1f;
			this.hasAlpha = hasAlpha;
			this.alpha = alpha;
			this.metallic = 0f;
			this.smooth = 0.562f;
		}

		// Token: 0x06000AE5 RID: 2789 RVA: 0x0003ED2C File Offset: 0x0003CF2C
		public override void Save(BinaryWriter writer)
		{
			base.Save_ColorType(writer);
			writer.Write(this.offset_h);
			writer.Write(this.offset_s);
			writer.Write(this.offset_v);
			writer.Write(this.alpha);
			writer.Write(this.metallic);
			writer.Write(this.smooth);
		}

		// Token: 0x06000AE6 RID: 2790 RVA: 0x0003ED88 File Offset: 0x0003CF88
		public override bool Load(BinaryReader reader, CUSTOM_DATA_VERSION version)
		{
			Color white = Color.white;
			if (version < CUSTOM_DATA_VERSION.DEBUG_04)
			{
				base.ReadColor(reader, ref white);
				return true;
			}
			COLOR_TYPE color_TYPE = ColorParameter_Base.Load_ColorType(reader, version);
			if (color_TYPE == COLOR_TYPE.NONE)
			{
				return false;
			}
			if (color_TYPE != this.GetColorType())
			{
				bool flag = false;
				if (version < CUSTOM_DATA_VERSION.DEBUG_06 && color_TYPE == COLOR_TYPE.ALLOY)
				{
					flag = true;
				}
				else if (color_TYPE == COLOR_TYPE.ALLOY_HSV)
				{
					flag = true;
				}
				if (!flag)
				{
					GlobalData.Debug_LogError("颜色类型不同");
				}
			}
			if (version < CUSTOM_DATA_VERSION.DEBUG_06)
			{
				base.ReadColor(reader, ref white);
			}
			else
			{
				this.offset_h = reader.ReadSingle();
				this.offset_s = reader.ReadSingle();
				this.offset_v = reader.ReadSingle();
				if (version == CUSTOM_DATA_VERSION.DEBUG_07)
				{
					bool flag2 = reader.ReadBoolean();
					this.alpha = reader.ReadSingle();
				}
				else if (version >= CUSTOM_DATA_VERSION.TRIAL)
				{
					this.alpha = reader.ReadSingle();
				}
			}
			this.metallic = reader.ReadSingle();
			this.smooth = reader.ReadSingle();
			return true;
		}

		// Token: 0x06000AE7 RID: 2791 RVA: 0x0003EE80 File Offset: 0x0003D080
		public void FromSexyData(HSColorSet colorSet)
		{
		}

		// Token: 0x06000AE8 RID: 2792 RVA: 0x0003EE84 File Offset: 0x0003D084
		public override void SetToMaterial(Material material)
		{
			if (material == null)
			{
				return;
			}
			if (this.hasAlpha)
			{
				Color color = material.color;
				color.a = this.alpha;
				material.color = color;
			}
			material.SetFloat(CustomDataManager._Metal, this.metallic);
			material.SetFloat(CustomDataManager._Roughness, 1f - this.smooth);
		}

		// Token: 0x06000AE9 RID: 2793 RVA: 0x0003EEEC File Offset: 0x0003D0EC
		public void SetToMaterial(Material material, float addSmooth)
		{
			if (material == null)
			{
				return;
			}
			if (this.hasAlpha)
			{
				Color color = material.color;
				color.a = this.alpha;
				material.color = color;
			}
			float value = 1f - Mathf.Clamp01(this.smooth + addSmooth);
			material.SetFloat(CustomDataManager._Metal, this.metallic);
			material.SetFloat(CustomDataManager._Roughness, value);
		}

		// Token: 0x04000AD2 RID: 2770
		public float offset_h;

		// Token: 0x04000AD3 RID: 2771
		public float offset_s = 1f;

		// Token: 0x04000AD4 RID: 2772
		public float offset_v = 1f;

		// Token: 0x04000AD5 RID: 2773
		public bool hasAlpha;

		// Token: 0x04000AD6 RID: 2774
		public float alpha = 1f;

		// Token: 0x04000AD7 RID: 2775
		public float metallic;

		// Token: 0x04000AD8 RID: 2776
		public float smooth = 0.562f;
	}
}
